
package Controller;

import Model.conexionBD;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(name = "ServicioVerificaPaciente", urlPatterns = {"/ServicioVerificaPaciente"})
public class ServicioVerificaPaciente extends HttpServlet {
    String id;
    String respuesta = "";
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
      
          try {
          String id = request.getParameter("id");
          conexionBD c = new conexionBD("root","root","SAPCOMED_DATABASE");   
                        if(!"".equals(id)){
                            int i = c.buscarPaciente(Integer.parseInt(id));
                            if(i==1)
                                out.print("YUPI ESTA REGISTRADO");
                            else
                                out.print("NO ESTA REGISTRADO");
                                              }
        } catch(Exception e){
            e.getStackTrace();
            }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
  
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

 
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
